home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pinstaller / GLILogger.py < prev    next >
Text File  |  2005-08-22  |  1KB  |  51 lines

  1. """
  2. # Copyright 1999-2005 Gentoo Foundation
  3. # This source code is distributed under the terms of version 2 of the GNU
  4. # General Public License as published by the Free Software Foundation, a copy
  5. # of which can be found in the main directory of this project.
  6. Gentoo Linux Installer
  7.  
  8. $Id: GLILogger.py,v 1.9 2005/08/22 18:35:51 codeman Exp $
  9.  
  10. Logger is a singleton style generic logger object.
  11. """
  12.  
  13. import time
  14.  
  15. class Logger(object):
  16.  
  17.     _LOG_FILE_PATH = "install.log"
  18.     _SHARED_LOGGER = None
  19.  
  20.     ##
  21.     # Creates a shared logger like in GLIClientConfiguration
  22.     # @param cls It's just done like that.
  23.     def shared_logger(cls):
  24.         if Logger._SHARED_LOGGER == None:
  25.             Logger._SHARED_LOGGER = Logger()
  26.  
  27.         return Logger._SHARED_LOGGER
  28.  
  29.     ##
  30.     # Basic Initialization function.  Appends to the given logfile
  31.     # @param logfile=None file to log stuff to.
  32.     def __init__(self,logfile=None):
  33.         if logfile == None:
  34.             self._file = file(Logger._LOG_FILE_PATH, 'a')
  35.         else:
  36.             self._file = file(logfile,'a')
  37.  
  38.     ##
  39.     # Logs the given message to the logfile
  40.     # @param message Parameter description
  41.     def log(self, message):
  42.         self._file.write("GLI: " + time.strftime("%B %d %Y %H:%M:%S") + " - " + message + "\n")
  43.         self._file.flush()
  44.         
  45.     ##
  46.     # Inserts a mark into the logfile.
  47.     def mark(self):
  48.         self.log(" -- MARK -- ")
  49.  
  50.     shared_logger = classmethod(shared_logger)
  51.